package org.jeecg.modules.simulator.factory.park;

import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.simulator.factory.train.plan.Train2Parker;
import org.jeecg.modules.simulator.jsonot.ParkSaver;
import org.jeecg.modules.simulator.mapper.SimParkSaversMapper;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @program: simulator-b20240918
 * @description:
 * @author: renzhg
 * @create: 2024-10-17 09:08
 **/
@Slf4j
@Primary
@Service
public class ParkSaverService {

    @Resource
    SimParkSaversMapper simParkSaversMapper;

    @Getter
    List<Train2Parker> train2Parkers =new ArrayList<>();
    public void saveParkSaver() {
        List<ParkSaver> allParkSavers = simParkSaversMapper.getAllParkSavers();

        allParkSavers.forEach(parkSaver -> {
            Train2Parker train2Parker = new Train2Parker();
            train2Parker.setSavers(Integer.parseInt(parkSaver.getSavers()));
            train2Parker.setParkerId(parkSaver.getParkId());
            train2Parkers.add(train2Parker);
        });

    }
}
